<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="cn.school.mybatis.utils.MyBatisUtil" %>
<%@ page import="cn.school.mybatis.dao.SubjectDao" %>
<%@ page import="cn.school.mybatis.pojo.Subject" %><%--
  Created by IntelliJ IDEA.
  User: zhaoyang
  Date: 2020/8/4
  Time: 9:44 上午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>增加课程</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String name = request.getParameter("className");
    int subHour = new Integer(request.getParameter("classHour"));
    int subGrade = new Integer(request.getParameter("classGrade"));

    SqlSession sess = MyBatisUtil.getSqlSession();
    SubjectDao subjectDao = sess.getMapper(SubjectDao.class);
    Subject subject = new Subject(name, subHour, subGrade);
    int result = subjectDao.add(subject);
    sess.commit();
    MyBatisUtil.close(sess);
%>
<script>
    if (confirm("信息增加成功！")) {
<%--        <%--%>
<%--            response.sendRedirect("s_subjectAdd.jsp");--%>
<%--        %>--%>
        location.replace("s_subjectAdd.jsp");

    } else {
<%--        <%--%>
<%--            response.sendRedirect("../index.jsp");--%>
<%--        %>--%>
        location.replace("../index.jsp");
    }

</script>

</body>
</html>
